<?php
include TMPL_PATH . 'public/header.phtml';
?>
<style>
    .shopping-cart {
        background: url(/web/Tpl/default/images/cart/shopping-cart.png) no-repeat;
        background-size: 16px 14px;
    }

    .shopping-cart strong {
        padding-left: 20px;
    }
</style>
<div class="subnav">
    <div class="content-menu ib-a blue line-x">
        <div style="float:left;margin-right:50px;">
            <a href='javascript:;' class="on"><em>合作伙伴列表</em></a><span>|</span>
            <a href='<?php echo U('user/user_add', 'partner=1'); ?>'><em>添加合作伙伴</em></a>
        </div>
        <div style="color:#000;">
            <?php
            $designer_id = isset($search) && isset($search['designer_id']) ? $search['designer_id'] : -1;
            $rank_id = isset($search) && isset($search['rank_id']) ? $search['rank_id'] : 0;
            ?>
            <form name="searchform" action="__SELF__" method="post">
                <?php
                $searchtype = isset($search) && $search['searchtype'] ? $search['searchtype'] : 0;
                $searchkeyword = isset($search) && $search['keyword'] ? $search['keyword'] : null;
                ?>
                <select name="searchtype">
                    <option value="0" <?php if ($searchtype == 0) echo 'selected'; ?> >邮件地址</option>
                    <option value="1" <?php if ($searchtype == 1) echo 'selected'; ?> >会员名</option>
                </select>
                <input type="text" class="input-text" value="<?php echo $searchkeyword; ?>" name="keyword">
                <input type="submit" value="搜索" class="button" name="search">&nbsp;&nbsp;&nbsp;&nbsp;
                <a href="/gpadmin.php?m=user&a=user_address_list_export">导出客户信息</a>&nbsp;&nbsp;&nbsp;&nbsp;
            </form>
        </div>
    </div>
</div>
<div class="pad_10">
    <div class="table-list">
        <table width="100%" cellspacing="0">
            <thead>
            <tr>
                <th align='center' width="5%">序号</th>
                <th align='center' width="10%">姓名</th>
                <th align='center' width="10%">Email</th>
                <th align='center' width="10%">可用资金</th>
                <th align='center' width="5%">状态</th>
                <th align='center' width="10%">注册日期</th>
                <th align='center' width="10%">客户数</th>
                <th align='center' width="10%">订单数</th>
                <th>管理操作</th>
            </tr>
            </thead>
            <tbody>
            <?php
            if (isset($userList) && $userList):
                foreach ($userList as $k => $v):
                    ?>
                    <tr>
                        <td align='center'><?php echo $k + 1; ?></td>
                        <td align='center'><?php echo $v['nickname'] ? $v['nickname'] : ($v['first_name'] . ' ' . $v['last_name']); ?></td>
                        <td align='center'><?php echo $v['email'] ?></td>
                        <td align='center'><?php echo $v['user_money']; ?></td>
                        <td align="center"><?php if ($v['disabled'] == 1) { ?><font
                                    color="red">√</font><?php } else { ?><font color="blue">×</font><?php } ?></td>
                        <td align='center'><?php echo $v['reg_time'] > 0 ? date('Y-m-d H:i:s', $v['reg_time']) : null; ?></td>
                        <td align='center'><?php echo $v['user_count']; ?></td>
                        <td align='center'><?php echo $v['order_count']; ?></td>
                        <td align='left' style="padding-left:100px;">
                            <a href="<?php echo U('user/user_edit', 'partner=1&uid=' . $v['id']); ?>">基本信息</a>&nbsp;&nbsp;|&nbsp;&nbsp;
                            <a href="<?php echo U('user/partner_address_list', 'partner=1&uid=' . $v['id']); ?>">客户信息</a>&nbsp;&nbsp;|&nbsp;&nbsp;
                            <a href="<?php echo U('user/account_log_list', 'partner=1&uid=' . $v['id']); ?>">账户明细</a>&nbsp;&nbsp;|&nbsp;<br>
                            客户数据转移到&nbsp;<input type="text" class="partner_email"  size="10" placeholder="合作伙伴Email">&nbsp;
                            <a href="javascript:;" class="admin_notes_confirm" onclick="move_action($(this));" user_id="<?php echo $v['id']; ?>">确认转移</a>&nbsp;|&nbsp;
                        </td>
                    </tr>
                <?php
                endforeach;
            endif;
            ?>
            </tbody>
        </table>
        <div id="pages"><?php echo $pageShow; ?></div>
    </div>
</div>
</body>
</html>
<script type="text/javascript">

    function move_action(_this){
        var partner_email = _this.siblings(".partner_email").val();
        var id = _this.attr("user_id");
        $.ajax({
            type: 'POST',
            url: "<?php echo U('user/move_user_address');?>&user_id="+id,
            data: {'partner_email':partner_email},
            success: function(data) {
                data = JSON.parse(data);
                alert(data.msg);
                _this.siblings(".partner_email").val("");
            }
        });
    }

</script>